package pingan.com.imandtwo.module;

import java.util.HashMap;

import io.reactivex.Flowable;
import pingan.com.imandtwo.beans.BannerBean;
import pingan.com.imandtwo.beans.IsRegisterBean;
import pingan.com.imandtwo.beans.LoginBean;
import pingan.com.imandtwo.beans.ValidateCodeBean;
import pingan.com.imandtwo.interfaces.ApiServers;
import pingan.com.imandtwo.presenter.HttpPresenter;
import pingan.com.imandtwo.utils.HttpUtils;

/**
 * Created by xsj on 2018/2/5.
 */

public class HttpModel {

    private HttpPresenter presenter;

    public HttpModel(HttpPresenter presenter) {
        this.presenter = presenter;
    }

    public void getData(HashMap<String,String> map, String tag){

        ApiServers api = HttpUtils.getInstance().getapi();

        //轮播的请求
        if(tag.equals("轮播")){
            Flowable<BannerBean> cart = api.getCart(map);
            presenter.getLunBoData(cart,tag);
        }

        //登录
        if(tag.equals("登录")){
            Flowable<LoginBean> login = api.getLogin(map);
            presenter.getLoginData(login,tag);
        }

        //发送注册的验证码
        if(tag.equals("注册验证码")){
            Flowable<ValidateCodeBean> phoneNumber = api.getPhoneNumber(map);
            presenter.getPhoneNumber(phoneNumber,tag);
        }

        //注册
        if(tag.equals("注册")){
            Flowable<ValidateCodeBean> zhuCeData = api.getZhuCeData(map);
            presenter.getZhuCeData(zhuCeData,tag);
        }

        //判断手机号是否注册
        if(tag.equals("是否注册")){
            Flowable<IsRegisterBean> zhuCePhone = api.getZhuCePhone(map);
            presenter.getIsRegister(zhuCePhone,tag);
        }

        //修改密码
        if(tag.equals("修改密码")){
            Flowable<ValidateCodeBean> updatePsd = api.getUpdatePsd(map);
            presenter.getUpdatepsd(updatePsd,tag);
        }

        //修改密码
        if(tag.equals("添加好友")){
            Flowable<ValidateCodeBean> addFriend = api.getAddFriend(map);
            presenter.getZhuCeData(addFriend,tag);
        }
    }
}
